<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>px和rem的换算</title>
	<style>
	    div {
	    	margin-top: 20px; 
	    }
		label {
			display: inline-block; 
			width: 200px; 
			text-align: right; 
		}
	</style>
</head>
<body>
	<h1>输入数值进行换算</h1>
	<div>
		<label for="px">px值</label>
		<input type="text" id="px" size="6">
	</div>
    <div>
    	<label for="rhtml">html的font-size值</label>
		<input type="text" id="rhtml" size="6">
    </div>
    <div>
    	<button id="btn" type="button" style="margin-left:220px; " onclick="jisuan()">计算</button>
    </div>
    <div>
    	<label for="rem">rem的值</label>
    	<input type="text" id="rem" size="6">
    </div>
    <script>
    	// var btn = document.getElementById("btn");
    	function jisuan() {
    		var px = document.getElementById("px");
    		var rhtml = document.getElementById("rhtml");
    		var rem = document.getElementById("rem");
    		rem.value = (px.value/rhtml.value).toFixed(7);
    	}
    </script>
</body>
</html>